import { createBrowserRouter } from "react-router-dom"
import Layout from "@/pages/Layout/index.js"
import Login from "../pages/Login"
import { AuthRoute } from "@/components/AuthRoute"
// import Home from "@/pages/home"
// import Article from "@/pages/article"
// import Publish from "@/pages/publish"
import { lazy, Suspense } from "react"
const Home = lazy(() => import('@/pages/home'))
const Article = lazy(() => import('@/pages/article'))
const Publish = lazy(() => import('@/pages/publish'))
const router = createBrowserRouter([
  {
    path:'/',
    element:<AuthRoute><Layout/></AuthRoute>,
    children:[
      {
        index:true,
        element:<Suspense fallback={'加载中'}><Home/></Suspense>
      },
      {
        path:'article',
        element:<Suspense fallback={'加载中'}><Article/></Suspense>
      },
      {
        path:'publish',
        element:<Suspense fallback={'加载中'}><Publish/></Suspense>
      }
    ]
  },
  {
    path:'/login',
    element:<Login/>
  }
])
export default router